package com.changwu.cwbase.temples.activity;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.ViewPager;

import com.changwu.cwbase.R;
import com.changwu.cwbase.base.ActivityBase;
import com.changwu.cwbase.temples.adapter.TempTabLayoutAdapter;

import butterknife.BindView;

/*
 * 顶部选项卡使用模板
 */
public class TempTabLayoutActivity extends ActivityBase{
    @BindView(R.id.tl)
    TabLayout tl;
    @BindView(R.id.vp)
    ViewPager vp;
    private TempTabLayoutAdapter adapter;
    private FragmentManager fragmentManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tablayout);
        initView();
    }

    @Override
    public void initToolBar() {
        super.initToolBar();
        title.setText("模板");
    }

    private void initView() {
        fragmentManager = getSupportFragmentManager();
        adapter = new TempTabLayoutAdapter(fragmentManager);
        vp.setOffscreenPageLimit(2);
        vp.setAdapter(adapter);
        tl.setupWithViewPager(vp);
    }

    /* @OnClick({R.id.back})
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.back:
                finish();
                break;
        }
    }*/
}
